#include "stdafx.h"
#include "FunctionBlockInterface.h"
#include "Global_Constants.h"
#include "Error.h"
#include "ErrorID.h"


FunctionBlockInterface::FunctionBlockInterface(void)
{
    // initializing input and output arrays
    Input = new double [MaxPortNumber];
    Output = new double [MaxPortNumber];
}

// Setting value for the Input port
void FunctionBlockInterface::SetInputPortValue(uint Index, double Value)
{
    if(Index < MaxPortNumber)
    {
        Input[Index] = Value;
    }
    else
    {
        ErrorDisplay(SET_IPT_PRT_IDX_EXCEDDED_MAX_PRTS_NUM);//_PORT_WITH_INDEX_EXCEDDED_MAXIMUM_PORT_NUMBER);
    }
}

// Setting value for the Onput port
void FunctionBlockInterface::SetOutputPortValue(uint Index, double Value)
{
    if(Index < MaxPortNumber)
    {
        Output[Index] = Value;
    }
    else
    {
        ErrorDisplay(SET_OPT_PRT_IDX_EXCEDDED_MAX_PRTS_NUM);
    }
}

// Getting value for the Input port
double FunctionBlockInterface::GetInputPortValue(uint Index)
{
    if(Index < MaxPortNumber)
    {
        return Input[Index];
    }
    else
    {
        ErrorDisplay(GET_IPT_PRT_IDX_EXCEDDED_MAX_PRTS_NUM);//_PORT_WITH_INDEX_EXCEDDED_MAXIMUM_PORT_NUMBER);
        return 0;
    }
}

// Getting value for the Output port
double FunctionBlockInterface::GetOutputPortValue(uint Index)
{
    if(Index < MaxPortNumber)
    {
        return Output[Index];
    }
    else
    {
        ErrorDisplay(GET_OPT_PRT_IDX_EXCEDDED_MAX_PRTS_NUM);
        return 0;
    }
}
